/**
 * spread operator展开运算符
 * 更快，更便捷的操作数组
 * 
 */

 function addNumbers(...numbers){
    return numbers.reduce((sum,number)=>{
        return sum+number;
    },0)
 }
 console.log(addNumbers(1,2,3,4,5,6,7,8))

 var defaultColors=["red","green"];
 var favoriteColors=["blue","pink"];

 //concat
//  defaultColors=defaultColors.concat(favoriteColors);
//  console.log(defaultColors);


console.log([...defaultColors,...favoriteColors]);
console.log("=============");
/**
 * 练习
 *   
 */

 function validateShoppingList(...items){
     if(items.indexOf('milk')<0){
         return["milk",...items];
     }
 }
 console.log(validateShoppingList("orange","bread","eggs"));